Repository navigation
fix: stop prefetches going untracked and old feed lists passing as fresh, and three smaller fixes - #341
Merged
therealsama merged 6 commits intoNov 22, 2026
Conversation
… view A story card prefetches its comments while it is in view and aborts the prefetch when it scrolls out. Scrolled back in before the aborted prefetch settled, the card started a new one, and the aborted one's cleanup then dropped the new one from the tracked prefetches. The untracked prefetch could no longer be aborted, didn't count toward the limit of three at a time, and the card's next return fetched the comments again while it was still running. A prefetch's cleanup now removes the entry only if it is still its own.
Opening a story from the list view saves the feed's session, and wrote the feed's list back to the cache stamped with the current time. A list fetched hours earlier then passed as just fetched for five minutes. Only the swipe view reads that freshness. In that time its background section prefetching skipped the feed instead of refreshing it, and it opened the feed on the old list's first story instead of waiting for the refresh. The list view refreshes a cached list every time it opens, so this showed only when one browser switched layouts within those five minutes, such as a phone turned to landscape and back. Saving the session now keeps the list's fetch time, and skips the write when the list has no cache entry: it is over a day old, or storage failed.
The Top feed is HN's current front page, then each earlier UTC day's front page from Algolia. Today's stories ranked 21 and below are never shown. That is by design, so say so where the feed moves on to yesterday.
A Hacker News poll option is an item of its own, with text and a score but no title. Read as a story, a link to one opened a page with an empty heading, the tab titled "HackerTok" and "No comments yet." The page also read the item again and searched Algolia for comments a poll option can't have, and held background prefetches until both answered. A poll option now keeps its type. The item page and the swipe view say poll options aren't supported, and title the tab after that notice. It fetches only the item, as a comment item does. A copy cached as a story before this change is corrected by the revalidation, whose type wins. Polls themselves still show like Ask posts: title, text and comments, without the options.
GitHub Pages serves 404.html for any path it has no file for, and its inline script redirects the path into the app's hash route. Vite copies public/ as is, so the build's CSP plugin never saw 404.html, and the page shipped with no CSP while every other page has one. 404.html is now a build entry beside index.html, so the plugin hashes its inline script into a CSP meta tag, and an e2e test checks it.
On the phone, a state shown in place of a swipe panel's content sat right under the header instead of in the middle of the screen. Its wrapper asked for `min-height: 100%`, but the active panel only has a min-height, so the percentage resolved to nothing. The state also jumped up when a swipe landed on it, because the peeking panel it came from has a definite height. The new `.full-screen-state` takes the panel's box under the header and above the offline bar. This covers the poll-option notice, the item's not-found and error states, the comment's error and deleted states, and the end-of-feed error. The empty illustration's rising dots also sat 2px left of the box's middle, on every layout. They now rise from its center, under "No comments yet" and the poll-option notice alike.
therealsama
force-pushed
the
fix/prefetch-restart-feed-cache-poll-options-404-csp
branch
from
November 22, 2026 18:10
f5c0f31 to
4626092
Compare
therealsama
enabled auto-merge
November 22, 2026 19:47
kplachkov
approved these changes
Nov 22, 2026
therealsama
deleted the
fix/prefetch-restart-feed-cache-poll-options-404-csp
branch
November 22, 2026 19:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes four bugs found in a review of the codebase and two layout bugs found while checking the new poll-option notice, and documents one design choice. Each commit passes typecheck, lint and the unit tests on its own.
Bug fixes
404.htmlhad no Content-Security-Policy. GitHub Pages serves it for every unknown path, and its inline script redirects the path into the app's hash route. Vite copied it frompublic/as is, so the CSP plugin never saw it. It is now a build entry besideindex.html, so its inline script is hashed into a CSP meta tag like the app's.min-height: 100%, but the active swipe panel only has a min-height, so the percentage resolved to nothing. Such a state also jumped up when a swipe landed on it, because the peeking panel it came from has a fixed height. It now fills the panel between the header and the offline bar. Desktop was already centered.The Top feed shows HN's current front page, then each earlier UTC day's front page from Algolia, so today's stories ranked 21 and below are never shown. That is by design, and a comment now says so.
Known limitations
StoryItemhas no field for the parent poll.Testing
npm run typecheck: passednpm run lint: passednpm run test:run: passed, 1199 tests in 64 filesgit rebase -x 'npm run typecheck && npm run lint && npx vitest run' main: every commit passed on its ownnpx playwright test --project=chromium --project="Mobile Chrome" --reporter=line --retries=0: 469 passed, 9 skipped. Its web server runsnpm run build, which passed.